package io.renren.modules.simida.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.simida.entity.SuggestionEntity;
import io.renren.modules.simida.service.SuggestionService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 意见反馈
 *
 * @author miaoguoxin
 * @email ${email}
 * @date 2019-11-27 14:04:59
 */
@RestController
@RequestMapping("simida/suggestion")
public class SuggestionController {
    @Autowired
    private SuggestionService suggestionService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("simida:suggestion:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = suggestionService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("simida:suggestion:info")
    public R info(@PathVariable("id") Long id){
		SuggestionEntity suggestion = suggestionService.getById(id);

        return R.ok().put("suggestion", suggestion);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("simida:suggestion:save")
    public R save(@RequestBody SuggestionEntity suggestion){
		suggestionService.save(suggestion);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("simida:suggestion:update")
    public R update(@RequestBody SuggestionEntity suggestion){
		suggestionService.updateById(suggestion);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("simida:suggestion:delete")
    public R delete(@RequestBody Long[] ids){
		suggestionService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
